package com.dxt.controller;

import com.dxt.pojo.Company;
import com.dxt.pojo.Delivery;
import com.dxt.service.CompanyService;
import com.dxt.service.CompanyServiceImpl;
import com.dxt.service.DeliveryService;
import com.dxt.service.DeliveryServiceImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import lombok.SneakyThrows;

import java.io.IOException;
import java.util.List;

/**
 * ClassName: DeliveryEditShowCompanyListController
 * Package: com.dxt.controller
 * Description:
 *
 * @Author 段鑫涛
 * @Create 2025/3/31 16:13
 * @Version 1.0
 */
@WebServlet("/delivery/getDeliveryEdit")
public class DeliveryEditShowController extends HttpServlet {
    private CompanyService companyService = new CompanyServiceImpl();
    private DeliveryService deliveryService = new DeliveryServiceImpl();
    @SneakyThrows
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Company> companyList = companyService.getCompanyList();
        String id = req.getParameter("id");
        Delivery delivery = deliveryService.getDeliveryListByDeliveryId(id);
        System.out.println("delivery = " + delivery);

        req.setAttribute("delivery", delivery);
        req.setAttribute("companyList", companyList);

        req.getRequestDispatcher("/edit.jsp").forward(req, resp);
    }
}
